<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const message = 'My aanamebb is WHY'

    // 需求:name必须是一个单独的词
    if (/name/i.test(message)) console.log('包含 name')
    // \b -> 词边界
    if (/\bname\b/i.test(message)) console.log('name是单独的单词')

    // 词边界的应用
    const infos = 'now time is 11:56, 12:00 ear food, number is 123:456'
    const timeRe = /\d\d:\d\d/ig
    console.log(infos.match(timeRe)) // ['11:56', '12:00', '23:45']

    const timeRe1 = /\b\d\d:\d\d\b/ig
    console.log(infos.match(timeRe1)) // ['11:56', '12:00']


  </script>
</body>

</html>